import request from '@/libs/request'
/**
 * 登录
 * @param data object 用户账号密码
 */

export function login (data) {
  return request.post('login', data, {
    login: false
  })
}

/**
 * 获取登录用户信息
 * @param token 用户账号密码
 */
export function getUserInfo () {
  return request.get('userinfo')
}

export function logout () {
  return request.get('logout')
}
/**
 * 修改用户登录密码
 * @param  用户密码
 */
export function merLoginPw (data) {
  return request.put('modifymerpw/'+data.uid,data,{ login: true })
}



export const getUnreadCount = () => {
  return axios.request({
    url: 'message/count',
    method: 'get'
  })
}

export const getMessage = () => {
  return axios.request({
    url: 'message/init',
    method: 'get'
  })
}

export const getContentByMsgId = msg_id => {
  return axios.request({
    url: 'message/content',
    method: 'get',
    params: {
      msg_id
    }
  })
}

export const hasRead = msg_id => {
  return axios.request({
    url: 'message/has_read',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const removeReaded = msg_id => {
  return axios.request({
    url: 'message/remove_readed',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const restoreTrash = msg_id => {
  return axios.request({
    url: 'message/restore',
    method: 'post',
    data: {
      msg_id
    }
  })
}
